package com.cheng.example.book.advise151.chap7.client114;

import java.io.IOException;

//父类

/**
 * 就这么一段简单的代码，展示了在构造函数中抛出受检异常的三个不利方面：
 *
 * 导致子类膨胀
 */
public class Base {
    // 父类抛出IOException
    public Base() throws IOException {
        throw new IOException();
    }

    public static void main(String[] args) {
        try {
           Base base = new Base();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

//子类
class Sub extends Base {

    // 子类抛出Exception异常
    public Sub() throws Exception {

    }

    public static void main(String[] args) {
        try {
            Base base = new Sub();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}


